﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using NS_QuangCaoTiepThiBUS;

namespace NS_QuangCaoTiepThi
{
    public partial class DangNhap : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnDangNhap_Click(object sender, EventArgs e)
        {
            Session["MaNguoiDung"] = txtMaNguoiDung.Text;
            
            NguoiDung ndDTO = new NguoiDung();
            ndDTO.MaNguoiDung = txtMaNguoiDung.Text.ToUpper();
            ndDTO.MatKhau = (new Security()).MaHoaSHA1(txtMatKhau.Text);

            NguoiDungBUS ndBUS = new NguoiDungBUS();
            string maLoaiNguoiDung = ndBUS.LayMaLoaiNguoiDung(ndDTO);
            Session["MaLoaiNguoiDung"] = maLoaiNguoiDung;
            if (maLoaiNguoiDung != null || maLoaiNguoiDung != string.Empty)
            {
                switch (maLoaiNguoiDung)
                {
                    case "TELLER":
                        Response.Redirect("QCTT/User/uHome.aspx");
                        break;

                    case "SUPERVISOR":
                        Response.Redirect("QCTT/User/uHome.aspx");
                        break;

                    case "ADMIN":
                        Response.Redirect("QCTT/Admin/aHome.aspx");
                        break;

                    default:
                        break;
                }
            }
        }

        protected void btnTroVe_Click(object sender, EventArgs e)
        {
            Session.Clear();

            Response.Redirect("Index.aspx");
        }
    }
}